<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return redirect('admin');
});


Route::post('admin/tourist_profile','Admin\TouristController@profile')->name('tourist.profile');


/*
 * admin login
 * */

Route::group(['middleware' => ['web']], function () {

    Route::any('admin/login', 'Admin\LoginController@login');
    Route::any('admin/logout', 'Admin\LoginController@logout');


    //测试上传excel
    Route::get('admin/upload', 'Admin\UploadController@index');
    Route::post('admin/upload', 'Admin\UploadController@post');

    Route::get('/admin/import_dsp', 'Admin\ImportDspController@index');
    Route::get('/admin/kafka', 'Admin\KafKaController@index');

    Route::get('/admin/testKafka', 'Admin\TestController@pushKafka');

});

/*
 * Admin routes
 * middleware : web admin.login
 * */
Route::group(['prefix' => 'admin', 'namespace' => 'Admin', 'middleware' => ['web', 'admin.view']], function () {

    //error
    Route::get('error', function () {
        return view('admin.error');
    })->name('admin.error');

    // index
    Route::get('/', 'IndexController@index')->name('index');

    // users

    Route::resource('user', 'UserController', [
        'names' => [
            'index' => 'user.index',
            'create' => 'user.create',
            'store' => 'user.store',
            'edit' => 'user.edit',
            'update' => 'user.update',
            'show' => 'user.show',
            'destroy' => 'user.destroy'
        ]
    ]);

    //source datas

    Route::resource('tourist', 'TouristController', [
        'names' => [
            'index' => 'tourist.index',
            'create' => 'tourist.create',
            'store' => 'tourist.store',
            'edit' => 'tourist.edit',
            'update' => 'tourist.update',
            'show' => 'tourist.show',
            'destroy' => 'tourist.destroy'
        ]
    ]);



    // action log
    Route::get('action_log', 'ActionLogController@index')->name('action_log');

    // menus
    Route::resource('menu', 'MenuController', [
        'names' => [
            'index' => 'menu.index',
            'create' => 'menu.create',
            'store' => 'menu.store',
            'edit' => 'menu.edit',
            'update' => 'menu.update',
            'show' => 'menu.show',
            'destroy' => 'menu.destroy'
        ]
    ]);
    Route::post('menu/sort', 'MenuController@sort')->name('menu.sort');

    // roles
    Route::resource('role', 'RoleController', [
        'names' => [
            'index' => 'role.index',
            'create' => 'role.create',
            'store' => 'role.store',
            'edit' => 'role.edit',
            'update' => 'role.update',
            'show' => 'role.show',
            'destroy' => 'role.destroy'
        ]
    ]);

    // role menu

    Route::get('/role_menu/{role_id}', 'RoleMenuController@index')->name('role_menu');
    Route::post('/role_menu/{role_id}', 'RoleMenuController@store')->name('role_menu_post');

});
